public abstract class Employee {
    protected String name;
    protected String id;

    public Employee(String name, String id) {
        this.name = name;
        this.id = id;
    }

    public abstract double calculateSalary() throws WorkTimeException;

    public String generatePayroll() {
        try {
            return String.format("=== 工资条 ===\n姓名: %s\n工号: %s\n职位: %s\n实发工资: %.2f元",
                    name, id, getPosition(), calculateSalary());
        } catch (WorkTimeException e) {
            return String.format("=== 工资条 ===\n姓名: %s\n工号: %s\n错误: %s", name, id, e.getMessage());
        }
    }

    protected abstract String getPosition();
    public String getName() { return name; }
    public String getId() { return id; }
}